$html
$html : string
Contains the HTML content to convert.
Converts HTML to formatted plain text
$html : string
Contains the HTML content to convert.
$text : string
Contains the converted, formatted text.
$width : int
Maximum width of the formatted text, in columns.
Set this value to 0 (or less) to ignore word wrapping and not constrain text to a fixed-width column.
$charset : string
Target character encoding for output text
$search : array
List of preg* regular expression patterns to search for, used in conjunction with $replace.
$replace : array
List of pattern replacements corresponding to patterns searched.
$ent_search : array
List of preg* regular expression patterns to search for, used in conjunction with $ent_replace.
$ent_replace : array
List of pattern replacements corresponding to patterns searched.
$callback_search : array
List of preg* regular expression patterns to search for and replace using callback function.
$pre_search : array
List of preg* regular expression patterns to search for in PRE body, used in conjunction with $pre_replace.
$pre_replace : array
List of pattern replacements corresponding to patterns searched for PRE body.
$pre_content : string
Temp. PRE content
$allowed_tags : string
Contains a list of HTML tags to allow in the resulting text.
$url : string
Contains the base URL that relative links should resolve to.
$_converted : bool
Indicates whether content in the $html variable has been converted yet.
$_link_list : array
Contains URL addresses from links to be rendered in plain text.
$_do_links : bool
Boolean flag, true if a table of link URLs should be listed after the text.
__construct(string $source = '', bool $from_file = false, bool $do_links = true, int $width = 75, mixed $charset = 'UTF-8') : mixed
Constructor.
If the HTML source string (or file) is supplied, the class will instantiate with that source propagated, all that has to be done it to call get_text().
string | $source | HTML content |
bool | $from_file | Indicates $source is a file to pull content from |
bool | $do_links | Indicate whether a table of link URLs is desired |
int | $width | Maximum width of the formatted text, 0 for no limit |
mixed | $charset |
_converter(string $text) : mixed
Workhorse function that does actual conversion.
First performs custom tag replacement specified by $search and $replace arrays. Then strips any remaining HTML tags, reduces whitespace and newlines to a readable format, and word wraps the text to $width characters.
string | $text | Reference to HTML content string |
_build_link_list(string $link, string $display) : mixed
Helper function called by preg_replace() on link replacement.
Maintains an internal list of links to be displayed at the end of the text, with numeric indices to the original point in the text they appeared. Also makes an effort at identifying and handling absolute and relative links.
string | $link | URL of the link |
string | $display | Part of the text to associate number with |